<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@include file="/admin/include/includeAdminTaglibs.jsp" %>
<!Doctype html>
<t:base type="jquery,easyui1.5,dateformat"></t:base>
<c:set value="/admin/assessment/dataList?formId=${param.formId}" var="returnUrl"/>
<c:if test="${empty param.tag}"><c:set value="/admin/assessment/list" var="returnUrl"/></c:if>
<t:datagrid name="dataGrid" actionUrl="/admin/assessment/gradingList?dataId=${param.dataId}&formId=${param.formId}" fit="true" fitColumns="true" idField="dataId"  pageSize="20" title="${assessmentDataModel.dataName}${evaluationFormModel.formName}评级列表">
    <t:dgCol title="系统编号" field="gradingId" hidden="false"></t:dgCol>
    <t:dgCol title="评级名称" sortable="false" field="gradingName"></t:dgCol>
    <t:dgCol title="开始值" sortable="false" field="beginValue"></t:dgCol>
    <t:dgCol title="结束值" sortable="false" field="endValue"></t:dgCol>
    <t:dgToolBar title="添加" icon="icon-add" funname="openDialog" url="/admin/assessment/gradingForm?formId=${param.formId}&dataId=${param.dataId}&objId=${not empty param.dataId ? param.dataId : param.formId}&gradingType=${not empty param.dataId ? 2 : 1}" width="28%"></t:dgToolBar>
    <t:dgToolBar title="修改" icon="icon-edit" funname="editService" url="/admin/assessment/gradingForm" width="28%" idFiledName="gradingId"></t:dgToolBar>
    <t:dgToolBar title="返回${not empty param.dataId ? '资料' : '评级'}" icon="icon-back" funname="backUrl" url="${returnUrl}" width="28%"></t:dgToolBar>
</t:datagrid>
<script>
    var buttons = [{
        text: '确认',
        iconCls: 'icon-ok',
        handler: function () {
            submitForm()
        }
    }, {
        text: '关闭',
        iconCls: 'icon-cancel',
        handler: function () {
            $dialog.window("close")
        }
    }];
    $("#formObj").form({
        url: '${frontPath}/admin/assessment/gradingSave',
        onSubmit: function () {
            var flag = $(this).form('validate');
            return flag;
        },
        success: function (resultObj) {
            var tip="成功"
            resultObj=$.parseJSON(resultObj)
            if(!resultObj.success){
                tip="失败"
            }
            top.showMessage("${empty item.loginId ? '添加' : '修改'}评级"+tip)
            top.reloadContentGird();
            top.closeDialog()
        }
    })
    function submitForm(){
        $("#formObj").submit()
    }
    function openDialog(title, url, gridId, width, height) {
        $dialog = $("<div></div>").dialog({
            title: title,
            href: url,
            modal: true,
            width:300,
            height:200,
            buttons: buttons,
            onClose: function () {
                $(this).window("window").nextAll('.window-shadow,.window-mask').remove()
                $(this).window("window").remove()
            }
        })
    }
    function editService(title, url, gridId, width, height, idFiledName) {
        var rowsData = $("#" + gridId).datagrid('getSelected');
        if (rowsData == null) {
            top.tip('请选择要修改的评级');
            return;
        }
        url += '?gradingId=' + rowsData[idFiledName]
        openDialog("修改评级",url)
    }

    function loadDataContentIFrameLoadUrl(title, url, gridId, width, height, idFiledName) {
        var rowsData = $("#" + gridId).datagrid('getSelected');
        if (rowsData == null) {
            top.tip('请选择要设置资料');
            return;
        }
        url += '?dataId=' + rowsData[idFiledName]+"&formId=${param.formId}"
        top.document.getElementById("contentIFrame").src=url
    }
    function backUrl(title, url) {
        top.document.getElementById("contentIFrame").src=url
    }
</script>